# 消费者
# 使用PullConsumer时
from rocketmq.client import PullConsumer
import redis

consumer = PullConsumer('CID_test')
consumer.set_namesrv_addr('127.0.0.1:32312')
consumer.start()

for msg in consumer.pull('TopicA'):
    print(msg.id, msg.body)
    r = redis.Redis(host='127.0.0.1', port=31022,db=0)
    r.set(msg.id,msg.body)   #添加
    print (r.get(msg.id))   #获取
consumer.shutdown()



# PushConsumer与此类似
# from rocketmq.client import PushConsumer